<%@ include file="/common/taglibs.jsp"%>
<title><fmt:message key="appAdminDetail.title"/></title>

<content tag="buttons">		
	<probiz:iconBtn btnType="save" onclick="saveAppAdmin()"/>
	<c:if test="${!appAdmin.isSuperAdmin}">
	   	<probiz:iconBtn btnType="delete" onclick="deleteAppAdmin()" disabled="yes"/>
	</c:if>
   	<probiz:iconBtn btnType="back" onclick="returnToList();" />
	<c:if test="${(not empty appAdmin.appuserId) and appAdmin.username!='admin'}">
		<div class="line"></div>
		<probiz:iconBtn btnType="resetPw" btnTextKey="button.resetPw" onclick="dlgresetPasswordDialog_show({appuserId:${appAdmin.appuserId}})"/>
	</c:if>
</content>
<div id="errorMsgExtraBar" class='warning_msg' style="display: none"/>
<div id="successMsgExtraBar" class="success_msg" style="display: none"/>
    	
<div class="top clearfix">
	<ul class="tab">
		<li class="curr"><span><fmt:message key="appAdminDetail.title"/></span></li>
	</ul>
</div>
<div class="modify">
	<form class="mainForm" method="post" action="${ctxPath}/system/appAdmin.html" id="appAdmin">
		<input type="hidden" name="appAdminId" id="appAdminId" value="${appAdmin.appuserId}"/> 
		<table width="100%" border="0" cellspacing="0" cellpadding="0" class="com_modi_table">
			<tr>
				<th colspan="2" class="title"><h4><fmt:message key="appAdmin.group.basic"/></h4></th>
			</tr>
			<tr>
		        <th class="label_width_1">
		            <StoreAdmin:label key="appAdmin.username"/>
		        </th>
		        <td>
					<c:choose>
						<c:when test="${not empty appAdmin.appuserId}">
							${appAdmin.username}
						</c:when>
						<c:otherwise>
							<input class="inputtxt" style="width: 350px"  maxlength="64" type="text" name="username" id="username" value="${appAdmin.username}"/>
							<probiz:plugin_tip id="usernameTip"><fmt:message key="appUser.userName.rule"/></probiz:plugin_tip>
						</c:otherwise>
					</c:choose>
				</td>
			</tr>
			<tr>
		        <th>
		            <StoreAdmin:label key="appAdmin.email"/>
		        </th>
		        <td>
					<input class="inputtxt" style="width: 350px"  maxlength="64" type="text" name="email" id="email" value="${appAdmin.email}"/>
				</td>
			</tr>
			<tr>
		        <th >
		            <StoreAdmin:label key="appAdmin.firstname"/>
		        </th>
		        <td>
					<input class="inputtxt" style="width: 350px"  maxlength="64" type="text" name="firstname" id="firstname" value="${appAdmin.firstname}"/>
				</td>
			</tr>
			<tr>
		        <th >
		            <StoreAdmin:label key="appAdmin.telephone"/>
		        </th>
		        <td>
					<input class="inputtxt" style="width: 350px"  maxlength="64" type="text" name="telephone" id="telephone" value="${appAdmin.telephone}"/>
				</td>
			</tr>
			
		    <tr>
		        <th class="field120" width="20%" nowrap="nowrap">
		            <StoreAdmin:label key="appAdmin.userPosition"/>
		        </th>
		        <td>
	            	<input class="inputtxt" style="width: 350px"  maxlength="64" type="text" name="userPosition" id="userPosition" value="${appAdmin.userPosition}"/>
		        </td>
		    </tr>
		    <c:if test="${empty appAdmin.appuserId}">
				<tr>
					<th colspan="2" class="title"><h4><fmt:message key="appUser.password.set"/></h4></th>
				</tr>	
				<tr>
			        <th >
			            <fmt:message key="appAdmin.password"/>(<span class="red">*</span>):
			        </th>
			        <td>
						<input class="inputtxt" style="width: 350px"  maxlength="64" type="password" name="password" id="password_" value=""/>
						<probiz:plugin_tip id="passwordTip"><fmt:message key="appUser.password.rule"/></probiz:plugin_tip>
					</td>
				</tr>
				<tr>
			       <th >
			            <fmt:message key="appAdmin.confirmPassword"/>(<span class="red">*</span>):
			        </th>
			        <td>
						<input class="inputtxt" style="width: 350px" maxlength="64" type="password" name="confirmPassword" id="confirmPassword"/>
					</td>
				</tr>
			</c:if>
			<c:if test="${!appAdmin.isSuperAdmin}">
				<tr>
					<th colspan="2" class="title"><h4><fmt:message key="appRole.roleAssign"/></h4></th>
				</tr>
				<tr>
					<th><StoreAdmin:label key="appUser.roles"/>(<span class="red">*</span>)</th>
					<td>
						<span>
							<c:set var="roleString" value=",${appAdmin.roleIdString},"/>
							<select id="appRoleIds" name="appRoleIds" multiple="multiple" style="width:200px;height:200px;" class="selecttxt">
								<c:forEach items="${allRoles}" var="userRole">
									<c:set var="roleId" value=",${userRole.roleId},"/>
									<option value="${userRole.roleId}" <c:if test="${fn:indexOf(roleString,roleId)!=-1}">selected</c:if>>${userRole.roleName}</option> 
								</c:forEach>
							</select>
						</span>
						<input type="button" onclick="document.getElementById('appRoleIds').selectedIndex=-1;" value="&nbsp;<fmt:message key="resource.roles.clear"/>&nbsp;" class="btn-common"/>
					</td>
				</tr>
			</c:if>
		</table>
	</form>
</div>

<v:javascript formName="appAdmin" staticJavascript="false"></v:javascript>
<script type="text/javascript">
$j(document).ready(function () {
	displayButtons(${appAdmin.status}); 
	
	applyValidate($("appRoleIds"),"required");
	<c:if test="${empty appAdmin.appuserId}">
		applyValidate($("password_"),"required,minlength=6,maxlength=16");
		applyValidate($("confirmPassword"),"required,minlength=6,maxlength=16,twofields=password_");
	</c:if>
});
	
</script>


					
